package com.learner.major.common;

import com.learner.pojo.major.Major;
import org.apache.commons.lang3.StringUtils;

public class MajorUtil {


    public static boolean isNullForUpdate(Major majorInf) {
        Boolean isFlag = true;
        String majorname = majorInf.getMajorName();
        String id = majorInf.getId();
        if (majorname != null && id != null) {
            isFlag = false;
        }
        return isFlag;
    }

/*
    public static boolean isNullForAdd(Major majorInf) {
        Boolean isFlag = true;
        String majorName = majorInf.getMajorName();
        String mainCourse = majorInf.getMainCourse();
        String careerProspects = majorInf.getCareerProspects();
        String researchDirection = majorInf.getResearchDirection();
        String trainingObjective = majorInf.getTrainingObjective();
        if (StringUtils.isNotBlank(majorName) && StringUtils.isNotBlank(mainCourse) && StringUtils.isNotBlank(careerProspects) && StringUtils.isNotBlank(researchDirection) && StringUtils.isNotBlank(trainingObjective)) {
            isFlag = false;
        }
        return isFlag;
    }*/


    //regex对输入特殊字符转义

    public static String escapeExprSpecialWord(String keyword) {

        if (StringUtils.isNotBlank(keyword)) {

            String[] fbsArr = {"\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|"};

            for (String key : fbsArr) {

                if (keyword.contains(key)) {
                    keyword = keyword.replace(key, "\\" + key);
                }
            }
        }

        return keyword;
    }

}
